home *** CD-ROM | disk | FTP | other *** search
/ Aminet 3 / Aminet 3 - July 1994.iso / Aminet / util / gnu / WinGnuPlot.lha / WinGnuPlot / Source / WinPlot.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-13  |  2.7 KB  |  131 lines

  1. #include "struct.c"
  2. #include "WinPlot.h"
  3. #include "amigawin.h"
  4.  
  5. /* at least Kick20 is required */
  6. long __oslibversion = 36;
  7. void __regargs __autoopenfail(char *);
  8.  
  9. /* the library bases */
  10. struct Library       *MUIMasterBase = NULL;
  11. struct FileRequester *FileReq = NULL;
  12.  
  13. /* some private definitions */
  14. static struct MsgPort *GnuPort = NULL;
  15.  
  16. int _STI_200_OpenMUI(void)
  17. {
  18.  if (!(MUIMasterBase = OpenLibrary("muimaster.library", MUIMASTER_VMIN)))
  19.   {
  20.    __oslibversion = MUIMASTER_VMIN;
  21.    __autoopenfail("mui.library");
  22.    return 1;
  23.   }
  24.  return 0;
  25. }
  26.  
  27. void _STD_200_CloseMUI(void)
  28. {
  29.  if (MUIMasterBase)
  30.   CloseLibrary(MUIMasterBase);
  31. }
  32.  
  33. int _STI_OpenSystem(void)
  34. {
  35.  char Buffer[255];
  36.  
  37.  GetCurrentDirName(Buffer, 255);
  38.  if (!(FileReq = MUI_AllocAslRequestTags(ASL_FileRequest,
  39.                      ASLFR_PrivateIDCMP,  TRUE,
  40.                      ASLFR_RejectIcons,   TRUE,
  41.                      ASLFR_InitialDrawer, Buffer,
  42.                      TAG_END)))
  43.   {
  44.    MUI_Request(NULL, NULL, 0, "WinPlot", "Ok", "CanĀ“t allocate FileRequest structure!\n");
  45.    return 1;
  46.   }
  47.  
  48. #ifndef _DEBUG
  49.  if (!FindPort(GNUREPLY))
  50.   {
  51.    MUI_Request(NULL, NULL, 0, "WinPlot", "Ok",
  52.            "This is a GnuPlot terminal driver, Please start GnuPlot first !");
  53.    return 1;
  54.   }
  55. #endif
  56.  
  57.  return 0;
  58. }
  59.  
  60. void _STD_CloseSystem(void)
  61. {
  62.  if (FileReq) MUI_FreeAslRequest(FileReq);
  63. }
  64.  
  65. ULONG main(void)
  66. {
  67.  BOOL                Quit = FALSE;
  68.  ULONG               PortFlag, RexxReplyFlag;
  69.  struct PlotMessage *PlotMsg;
  70.  
  71.  if (GnuPort = CreatePort(GNUPORT, 0))
  72.   {
  73.    PortFlag = 1 << GnuPort->mp_SigBit;
  74.    RexxReplyFlag = 1 << RexxReplyPort->mp_SigBit;
  75.  
  76.    if (AP_WinPlot = GetGUI())
  77.    {
  78.     set(WI_WinPlot, MUIA_Window_Open, TRUE);
  79.     
  80.     while (!Quit)
  81.      {
  82.       ULONG MUI_ID, MUI_Signal, Sig;
  83.       
  84.       MUI_ID = DoMethod(AP_WinPlot, MUIM_Application_Input, &MUI_Signal);
  85.       if (MUI_ID != 0)
  86.        Quit = HandleMUI(MUI_ID);
  87.       if (MUI_Signal)
  88.        Sig = Wait(MUI_Signal|PortFlag|RexxReplyFlag);
  89.       else
  90.        Sig = 0L;
  91.       
  92.       if (Sig & PortFlag)
  93.        while (PlotMsg = (struct PlotMessage *)GetMsg(GnuPort))
  94.     {
  95.      switch(PlotMsg->PlotCom.gpc_com)
  96.       {
  97.       case SET_GRAPHICS:
  98.        set(AP_WinPlot, MUIA_Application_Sleep, TRUE);
  99.        break;
  100.       case SET_TEXT:
  101.        ncommands = PlotMsg->PlotCom.gpc_ncommands;
  102.        commands = PlotMsg->PlotCom.gpc_commands;
  103.        set(AP_WinPlot, MUIA_Application_Sleep, FALSE);
  104.        Refresh();
  105.        break;
  106.       case RESET:
  107.        Quit = TRUE;
  108.        DoMethod(AP_WinPlot, MUIM_Application_Save, CONFIG);
  109.        break;
  110.       case SETVAR:
  111.        Settings((struct SetVar *)PlotMsg->PlotCom.gpc_arg);
  112.        break;
  113.       case PAUSE:
  114.        WaitRequest(PlotMsg->PlotCom.gpc_arg);
  115.        break;
  116.       }
  117.     
  118.      ReplyMsg(PlotMsg);
  119.     }
  120.       if (Sig & RexxReplyFlag)
  121.        if (GetMsg(RexxReplyPort))
  122.     ReplyRexxMsg();
  123.      }
  124.     MUI_DisposeObject(AP_WinPlot);
  125.    }
  126.    DeletePort(GnuPort);
  127.   }
  128.  
  129.  return 0;
  130. }
  131.